﻿// 途龙科技

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using TestItems.Model;
using TlToolCordCreate.Web;

namespace TestItems.Mode;
public class MainPageMode: ObservableObject
{
    public ICommand TCommand;
    public ICommand GetToken;
    private bool _hasToken;
    /// <summary>
    /// 是否有token
    /// </summary>
    public bool HasToken { get => _hasToken; set => SetProperty(ref _hasToken, value); }
    public MyWebRequest webRequest { get; set; }

    public MainPageMode() 
    {
        webRequest=new MyWebRequest();
        TCommand = new RelayCommand(execute: FunTCommand);
        GetToken = new RelayCommand(execute: FunGetToken);
    }

    public void FunGetToken()
    {
        
        webRequest.GetToken(new Action<bool>((callback) =>
        {
            HasToken = callback;
        }));
    }

    public void FunTCommand()
    {
        MesOrdreInput input = new MesOrdreInput()
        { 
            Code=Guid.NewGuid().ToString(),
            IsOverwriteTasks=false,
            Device= "CNC1",
            Product= "测试产品",
            ToolDetial=new List<MesToolRequestData>()
            {
                new MesToolRequestData()
                {
                    Count=2,
                    ToolType="铣刀",
                },
                new MesToolRequestData()
                {
                    ToolType="圆柱形球头模具铣刀",
                    Count=2,
                }
            }
        };
        webRequest.AddMesTask(input);
    }
}
